import { IPSCodeList } from './ipscode-list';
import { PSCodeItemImpl } from './pscode-item-impl';
import { IPSDataEntity } from '../dataentity/ipsdata-entity';
import { IPSDEField } from '../dataentity/defield/ipsdefield';
import { IPSDEDataSet } from '../dataentity/ds/ipsdedata-set';
import { IPSLanguageRes } from '../res/ipslanguage-res';
import { IPSSysPFPlugin } from '../res/ipssys-pfplugin';
import { IPSSysSFPlugin } from '../res/ipssys-sfplugin';
import { IPSSystemModule } from '../system/ipssystem-module';

export class PSCodeListImpl extends PSCodeItemImpl implements IPSCodeList {
  protected beginvaluepsdefield: IPSDEField | null = null;

  getBeginValuePSDEField(): IPSDEField | null {
    if (this.beginvaluepsdefield != null) return this.beginvaluepsdefield;
    const value = this.M.getBeginValuePSDEField;
    if (value == null) {
      return null;
    }
    const ipsdataentity = this.getPSDataEntity();
    if (ipsdataentity != null) {
      this.beginvaluepsdefield = ipsdataentity.findPSDEField(value);
    }
    return this.beginvaluepsdefield;
  }

  get beginValuePSDEField(): IPSDEField | null {
    return this.getBeginValuePSDEField();
  }

  getBeginValuePSDEFieldMust(): IPSDEField {
    const value = this.getBeginValuePSDEField();
    if (value == null) {
      throw new Error('未指定开始值属性');
    }
    return value;
  }

  get cacheTimeout(): number {
    return this.M.cacheTimeout != null ? this.M.cacheTimeout : -1;
  }

  get codeListTag(): string {
    return this.M.codeListTag;
  }

  get codeListType(): 'STATIC' | 'DYNAMIC' | 'PREDEFINED' {
    return this.M.codeListType;
  }

  get codeName(): string {
    return this.M.codeName;
  }

  get customCond(): string {
    return this.M.customCond;
  }

  protected datapsdefield: IPSDEField | null = null;

  getDataPSDEField(): IPSDEField | null {
    if (this.datapsdefield != null) return this.datapsdefield;
    const value = this.M.getDataPSDEField;
    if (value == null) {
      return null;
    }
    const ipsdataentity = this.getPSDataEntity();
    if (ipsdataentity != null) {
      this.datapsdefield = ipsdataentity.findPSDEField(value);
    }
    return this.datapsdefield;
  }

  get dataPSDEField(): IPSDEField | null {
    return this.getDataPSDEField();
  }

  getDataPSDEFieldMust(): IPSDEField {
    const value = this.getDataPSDEField();
    if (value == null) {
      throw new Error('未指定数据属性');
    }
    return value;
  }

  protected disablepsdefield: IPSDEField | null = null;

  getDisablePSDEField(): IPSDEField | null {
    if (this.disablepsdefield != null) return this.disablepsdefield;
    const value = this.M.getDisablePSDEField;
    if (value == null) {
      return null;
    }
    const ipsdataentity = this.getPSDataEntity();
    if (ipsdataentity != null) {
      this.disablepsdefield = ipsdataentity.findPSDEField(value);
    }
    return this.disablepsdefield;
  }

  get disablePSDEField(): IPSDEField | null {
    return this.getDisablePSDEField();
  }

  getDisablePSDEFieldMust(): IPSDEField {
    const value = this.getDisablePSDEField();
    if (value == null) {
      throw new Error('未指定禁用值属性');
    }
    return value;
  }

  get dynaInstMode(): 0 | 1 | 2 {
    return this.M.dynaInstMode;
  }

  get dynaInstTag(): string {
    return this.M.dynaInstTag;
  }

  get dynaInstTag2(): string {
    return this.M.dynaInstTag2;
  }

  get dynaModelFilePath(): string {
    return this.M.dynaModelFilePath;
  }

  get emptyText(): string {
    return this.M.emptyText;
  }

  protected emptytextpslanguageres: IPSLanguageRes | null = null;

  getEmptyTextPSLanguageRes(): IPSLanguageRes | null {
    if (this.emptytextpslanguageres != null) return this.emptytextpslanguageres;
    const value = this.M.getEmptyTextPSLanguageRes;
    if (value == null) {
      return null;
    }
    this.emptytextpslanguageres = this.getPSModel4('res.IPSLanguageRes', value, 'getEmptyTextPSLanguageRes') as IPSLanguageRes;
    return this.emptytextpslanguageres;
  }

  get emptyTextPSLanguageRes(): IPSLanguageRes | null {
    return this.getEmptyTextPSLanguageRes();
  }

  getEmptyTextPSLanguageResMust(): IPSLanguageRes {
    const value = this.getEmptyTextPSLanguageRes();
    if (value == null) {
      throw new Error('未指定空白显示文本语言资源');
    }
    return value;
  }

  protected endvaluepsdefield: IPSDEField | null = null;

  getEndValuePSDEField(): IPSDEField | null {
    if (this.endvaluepsdefield != null) return this.endvaluepsdefield;
    const value = this.M.getEndValuePSDEField;
    if (value == null) {
      return null;
    }
    const ipsdataentity = this.getPSDataEntity();
    if (ipsdataentity != null) {
      this.endvaluepsdefield = ipsdataentity.findPSDEField(value);
    }
    return this.endvaluepsdefield;
  }

  get endValuePSDEField(): IPSDEField | null {
    return this.getEndValuePSDEField();
  }

  getEndValuePSDEFieldMust(): IPSDEField {
    const value = this.getEndValuePSDEField();
    if (value == null) {
      throw new Error('未指定结束值属性');
    }
    return value;
  }

  protected iconclspsdefield: IPSDEField | null = null;

  getIconClsPSDEField(): IPSDEField | null {
    if (this.iconclspsdefield != null) return this.iconclspsdefield;
    const value = this.M.getIconClsPSDEField;
    if (value == null) {
      return null;
    }
    const ipsdataentity = this.getPSDataEntity();
    if (ipsdataentity != null) {
      this.iconclspsdefield = ipsdataentity.findPSDEField(value);
    }
    return this.iconclspsdefield;
  }

  get iconClsPSDEField(): IPSDEField | null {
    return this.getIconClsPSDEField();
  }

  getIconClsPSDEFieldMust(): IPSDEField {
    const value = this.getIconClsPSDEField();
    if (value == null) {
      throw new Error('未指定图标样式属性');
    }
    return value;
  }

  protected iconclsxpsdefield: IPSDEField | null = null;

  getIconClsXPSDEField(): IPSDEField | null {
    if (this.iconclsxpsdefield != null) return this.iconclsxpsdefield;
    const value = this.M.getIconClsXPSDEField;
    if (value == null) {
      return null;
    }
    const ipsdataentity = this.getPSDataEntity();
    if (ipsdataentity != null) {
      this.iconclsxpsdefield = ipsdataentity.findPSDEField(value);
    }
    return this.iconclsxpsdefield;
  }

  get iconClsXPSDEField(): IPSDEField | null {
    return this.getIconClsXPSDEField();
  }

  getIconClsXPSDEFieldMust(): IPSDEField {
    const value = this.getIconClsXPSDEField();
    if (value == null) {
      throw new Error('未指定图标样式(x)属性');
    }
    return value;
  }

  protected iconpathxpsdefield: IPSDEField | null = null;

  getIconPathXPSDEField(): IPSDEField | null {
    if (this.iconpathxpsdefield != null) return this.iconpathxpsdefield;
    const value = this.M.getIconPathXPSDEField;
    if (value == null) {
      return null;
    }
    const ipsdataentity = this.getPSDataEntity();
    if (ipsdataentity != null) {
      this.iconpathxpsdefield = ipsdataentity.findPSDEField(value);
    }
    return this.iconpathxpsdefield;
  }

  get iconPathXPSDEField(): IPSDEField | null {
    return this.getIconPathXPSDEField();
  }

  getIconPathXPSDEFieldMust(): IPSDEField {
    const value = this.getIconPathXPSDEField();
    if (value == null) {
      throw new Error('未指定图标路径(x)属性');
    }
    return value;
  }

  get incBeginValueMode(): 0 | 1 | 2 | 3 {
    return this.M.incBeginValueMode != null ? this.M.incBeginValueMode : 0;
  }

  get incEndValueMode(): 0 | 1 | 2 | 3 {
    return this.M.incEndValueMode != null ? this.M.incEndValueMode : 0;
  }

  get memo(): string {
    return this.M.memo;
  }

  get minorSortDir(): 'ASC' | 'DESC' {
    return this.M.minorSortDir;
  }

  protected minorsortpsdefield: IPSDEField | null = null;

  getMinorSortPSDEField(): IPSDEField | null {
    if (this.minorsortpsdefield != null) return this.minorsortpsdefield;
    const value = this.M.getMinorSortPSDEField;
    if (value == null) {
      return null;
    }
    const ipsdataentity = this.getPSDataEntity();
    if (ipsdataentity != null) {
      this.minorsortpsdefield = ipsdataentity.findPSDEField(value);
    }
    return this.minorsortpsdefield;
  }

  get minorSortPSDEField(): IPSDEField | null {
    return this.getMinorSortPSDEField();
  }

  getMinorSortPSDEFieldMust(): IPSDEField {
    const value = this.getMinorSortPSDEField();
    if (value == null) {
      throw new Error('未指定默认排序属性');
    }
    return value;
  }

  get name(): string {
    return this.M.name;
  }

  get orMode(): 'NUM' | 'STR' {
    return this.M.orMode;
  }

  get psCodeListTemplId(): string {
    return this.M.getPSCodeListTemplId;
  }

  getPSCodeListTemplId(): string {
    return this.M.getPSCodeListTemplId;
  }

  protected psdedataset: IPSDEDataSet | null = null;

  getPSDEDataSet(): IPSDEDataSet | null {
    if (this.psdedataset != null) return this.psdedataset;
    const value = this.M.getPSDEDataSet;
    if (value == null) {
      return null;
    }
    const ipsdataentity = this.getPSDataEntity();
    if (ipsdataentity != null) {
      this.psdedataset = ipsdataentity.findPSDEDataSet(value);
    }
    return this.psdedataset;
  }

  get psDEDataSet(): IPSDEDataSet | null {
    return this.getPSDEDataSet();
  }

  getPSDEDataSetMust(): IPSDEDataSet {
    const value = this.getPSDEDataSet();
    if (value == null) {
      throw new Error('未指定实体数据集对象');
    }
    return value;
  }

  protected psdataentity: IPSDataEntity | null = null;

  getPSDataEntity(): IPSDataEntity | null {
    if (this.psdataentity != null) return this.psdataentity;
    const value = this.M.getPSDataEntity;
    if (value == null) {
      return null;
    }
    this.psdataentity = this.getPSModel4('dataentity.IPSDataEntity', value, 'getPSDataEntity') as IPSDataEntity;
    return this.psdataentity;
  }

  get psDataEntity(): IPSDataEntity | null {
    return this.getPSDataEntity();
  }

  getPSDataEntityMust(): IPSDataEntity {
    const value = this.getPSDataEntity();
    if (value == null) {
      throw new Error('未指定实体对象');
    }
    return value;
  }

  protected pssyspfplugin: IPSSysPFPlugin | null = null;

  getPSSysPFPlugin(): IPSSysPFPlugin | null {
    if (this.pssyspfplugin != null) return this.pssyspfplugin;
    const value = this.M.getPSSysPFPlugin;
    if (value == null) {
      return null;
    }
    this.pssyspfplugin = this.getPSModel4('res.IPSSysPFPlugin', value, 'getPSSysPFPlugin') as IPSSysPFPlugin;
    return this.pssyspfplugin;
  }

  get psSysPFPlugin(): IPSSysPFPlugin | null {
    return this.getPSSysPFPlugin();
  }

  getPSSysPFPluginMust(): IPSSysPFPlugin {
    const value = this.getPSSysPFPlugin();
    if (value == null) {
      throw new Error('未指定前端扩展插件');
    }
    return value;
  }

  protected pssyssfplugin: IPSSysSFPlugin | null = null;

  getPSSysSFPlugin(): IPSSysSFPlugin | null {
    if (this.pssyssfplugin != null) return this.pssyssfplugin;
    const value = this.M.getPSSysSFPlugin;
    if (value == null) {
      return null;
    }
    this.pssyssfplugin = this.getPSModel4('res.IPSSysSFPlugin', value, 'getPSSysSFPlugin') as IPSSysSFPlugin;
    return this.pssyssfplugin;
  }

  get psSysSFPlugin(): IPSSysSFPlugin | null {
    return this.getPSSysSFPlugin();
  }

  getPSSysSFPluginMust(): IPSSysSFPlugin {
    const value = this.getPSSysSFPlugin();
    if (value == null) {
      throw new Error('未指定后台扩展插件');
    }
    return value;
  }

  protected pssystemmodule: IPSSystemModule | null = null;

  getPSSystemModule(): IPSSystemModule | null {
    if (this.pssystemmodule != null) return this.pssystemmodule;
    const value = this.M.getPSSystemModule;
    if (value == null) {
      return null;
    }
    this.pssystemmodule = this.getPSModel4('system.IPSSystemModule', value, 'getPSSystemModule') as IPSSystemModule;
    return this.pssystemmodule;
  }

  get psSystemModule(): IPSSystemModule | null {
    return this.getPSSystemModule();
  }

  getPSSystemModuleMust(): IPSSystemModule {
    const value = this.getPSSystemModule();
    if (value == null) {
      throw new Error('未指定系统模块');
    }
    return value;
  }

  protected pvaluepsdefield: IPSDEField | null = null;

  getPValuePSDEField(): IPSDEField | null {
    if (this.pvaluepsdefield != null) return this.pvaluepsdefield;
    const value = this.M.getPValuePSDEField;
    if (value == null) {
      return null;
    }
    const ipsdataentity = this.getPSDataEntity();
    if (ipsdataentity != null) {
      this.pvaluepsdefield = ipsdataentity.findPSDEField(value);
    }
    return this.pvaluepsdefield;
  }

  get pValuePSDEField(): IPSDEField | null {
    return this.getPValuePSDEField();
  }

  getPValuePSDEFieldMust(): IPSDEField {
    const value = this.getPValuePSDEField();
    if (value == null) {
      throw new Error('未指定父值属性');
    }
    return value;
  }

  get predefinedType(): 'OPERATOR' | 'RUNTIME' | 'MODULEINST' | 'DEMAINSTATE' | 'USER' | 'USER2' | 'USER3' | 'USER4' {
    return this.M.predefinedType;
  }

  get refFlag(): boolean {
    return this.M.refFlag;
  }

  get systemTag(): string {
    return this.M.systemTag;
  }

  protected textpsdefield: IPSDEField | null = null;

  getTextPSDEField(): IPSDEField | null {
    if (this.textpsdefield != null) return this.textpsdefield;
    const value = this.M.getTextPSDEField;
    if (value == null) {
      return null;
    }
    const ipsdataentity = this.getPSDataEntity();
    if (ipsdataentity != null) {
      this.textpsdefield = ipsdataentity.findPSDEField(value);
    }
    return this.textpsdefield;
  }

  get textPSDEField(): IPSDEField | null {
    return this.getTextPSDEField();
  }

  getTextPSDEFieldMust(): IPSDEField {
    const value = this.getTextPSDEField();
    if (value == null) {
      throw new Error('未指定显示文本属性');
    }
    return value;
  }

  get textSeparator(): string {
    return this.M.textSeparator;
  }

  get userData(): string {
    return this.M.userData;
  }

  get userData2(): string {
    return this.M.userData2;
  }

  protected valuepsdefield: IPSDEField | null = null;

  getValuePSDEField(): IPSDEField | null {
    if (this.valuepsdefield != null) return this.valuepsdefield;
    const value = this.M.getValuePSDEField;
    if (value == null) {
      return null;
    }
    const ipsdataentity = this.getPSDataEntity();
    if (ipsdataentity != null) {
      this.valuepsdefield = ipsdataentity.findPSDEField(value);
    }
    return this.valuepsdefield;
  }

  get valuePSDEField(): IPSDEField | null {
    return this.getValuePSDEField();
  }

  getValuePSDEFieldMust(): IPSDEField {
    const value = this.getValuePSDEField();
    if (value == null) {
      throw new Error('未指定值属性');
    }
    return value;
  }

  get valueSeparator(): string {
    return this.M.valueSeparator;
  }

  get codeItemValueNumber(): boolean {
    return this.M.codeItemValueNumber;
  }

  get enableCache(): boolean {
    return this.M.enableCache;
  }

  get moduleInstCodeList(): boolean {
    return this.M.moduleInstCodeList != null ? this.M.moduleInstCodeList : false;
  }

  get subSysAsCloud(): boolean {
    return this.M.subSysAsCloud;
  }

  get subSysCodeList(): boolean {
    return this.M.subSysCodeList;
  }

  get thresholdGroup(): boolean {
    return this.M.thresholdGroup != null ? this.M.thresholdGroup : false;
  }

  get userScope(): boolean {
    return this.M.userScope;
  }

  get cls(): string {
    return 'PSCodeListImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'codelist.IPSCodeList') return true;
    return super.instanceof(cls);
  }
}
